package com.cy.redistest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/redis")
public class redisController {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @GetMapping("/add")
    public void add(){
        redisTemplate.opsForValue().set("name", "yangrong");
    }
    @GetMapping("/get")
    public Object get(){
        String s = redisTemplate.opsForValue().get("name");
        return s;
    }
}
